package com.surfilter.geet;

import java.net.InetAddress;
import java.net.NetworkInterface;

public class RamdomUtil {
	
	public static String getLocalMac() {
		String mac_str = "";
		try{
			InetAddress ia = InetAddress.getLocalHost();
			byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
			StringBuffer sb = new StringBuffer("");
			for (byte aMac : mac) {
				int temp = aMac & 0xff;
				String str = Integer.toHexString(temp);
				if (str.length() == 1) {
					sb.append("0").append(str);
				} else {
					sb.append(str);
				}
			}
			System.out.println(""+sb.toString().toUpperCase());
			mac_str=sb.toString().toUpperCase();
		}catch (Exception e) {
			e.printStackTrace();
		}
		return mac_str;
	}
	
	public static String getRandomStr(int num) {
		String name = "";
		try {
			for (int i = 0; i < num; i++) {
				int intValue = (int) (Math.random() * 26 + 97);
				name = name + (char) intValue;
			}
			System.out.println("" + name);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return name;
	}

	public static String getRandomIntStr(int num) {
		String value = "";
		for (int i = 0; i < num; i++) {
			value += (int) (Math.random() * 10);
		}
		return value;
	}
	
	public static int getRandomInt(int num){
		int value = (int) (Math.random() * num);
		return value;
	}
	public static int getRandomNum(int min,int max) { 
		int random=(int)(Math.random()*(max+1-min))+min;
		return random;
	}
	
	public static int getRandomNumAbs(int min,int max){
		int target = getRandomNum(min, max);
		int res = getRandomNum(1, 2);
		if(res == 1){
			return target;
		}else{
			return -1 * target;
		}
	}
	
	public static double getRandomDouble(double min,double max ) { 
		double random=(Math.random()*(max-min))+min;
	    return random;   
	}
	
	public static void main(String[] args) {
		for(int i=0;i<100;i++){
			System.out.println(RamdomUtil.getRandomDouble(0.05, 0.04));
		}
//		System.out.println(RamdomUtil.getRandomStr(3));
//		System.out.println(RamdomUtil.getRandomIntStr(3));
	}
}
